package de.sonnentempel.framework;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {
	private static EntityManagerFactory emf;

	private JPAUtil() {
	}

	public static EntityManagerFactory getEntityManagerFactory() {

		if (emf == null) {
			try {
				emf = Persistence
				.createEntityManagerFactory("Default");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return emf;
	}

	public static EntityManager getEntityManager() {
		EntityManager em = getEntityManagerFactory().createEntityManager();

		return em;
	}
}
